﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="Index.aspx.cs" Inherits="Xiaov.SmartWeb.Application.PluginSrc.StatisticalSystem.Manage.Index" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript" src="/Resources/xiaovcn/scripts/usercheck.js"></script>
    <script type="text/javascript">

        var bbbms, dwbm, year, month, sbr,months;


        function showinfo(_dwbm, _nf, _yf, _bbbm,e,t) {
            //$('#test').window('open');
            var toolTip = "<div id='tooltip' style='position:absolute;border:solid #aaa 1px;background-color:#0081C2; padding:10px;color:#fff'></div>";
            $(t).after(toolTip);
            $('#tooltip').load("JYInfo.aspx?dwbm=" + _dwbm + "&nf=" + _nf + "&yf=" + _yf + "&bbbm=" + _bbbm,{"abc":111});
            $("#tooltip").css({ 
                "top" :e.pageY-108 + "px", 
                "left" :e.pageX + "px" 
            });
            
        }
        function hideinfo(_dwbm, _nf, _yf, _bbbm) {
            $('#tooltip').remove();
            //$('#test').load("JYInfo.aspx?dwbm=" + _dwbm + "&nf=" + _nf + "&yf=" + _yf + "&bbbm=" + _bbbm);
        }
        $.ajaxSetup({

            cache: false //关闭AJAX相应的缓存

        });

        function callback(res) {
            if (res.error==null) {               
                $('#tt').datagrid('reload');
                $.messager.alert('提示', '操作成功！');
            }
            else {
                $.messager.alert('提示', res.error);
            }
        }
        
        function getSelections() {
            var ss = [];
            var rows = $('#tt').datagrid('getSelections');
            for (var i = 0; i < rows.length; i++) {
                var row = rows[i];
                ss.push(row.BBBM);
            }
            return ss.join(',');
        }

        function getSelections_yf() {
            var ss = [];
            var rows = $('#tt').datagrid('getSelections');
            for (var i = 0; i < rows.length; i++) {
                var row = rows[i];
                ss.push(row.YF);
            }
            return ss.join(',');
        }

        function getReportSelections() {
            var ss = [];
            var rows = $('#tt').datagrid('getSelections');
            for (var i = 0; i < rows.length; i++) {
                var row = rows[i];
                if (unescape(row.SFTGJY) == "是")
                ss.push(row.BBBM);
            }
            return ss.join(',');            
        }

        $(function () {
            var lastIndex;//new
            //year=$('#ddl_Year').combobox('getValue');
            //month = $('#ddl_Month').combobox('getValue');
            //dwbm = $('#ddl_Owner').combobox('getValue');
            //sbr = $('#ddl_Sbr').combobox('getValue');

            year = $("#ddl_Year").val();
            month = $("#ddl_Month").val();
            dwbm = $("#ddl_Owner").val();
            sbr = $("#ddl_Sbr").val();

            $('#tt').datagrid({
                url: 'DataURL.aspx?dwbm='+dwbm+'&year='+year+'&month='+month,
                title: '报表列表', rownumbers: true,  fitColumns: false, singleSelect: false, striped: true,
                columns:
                [[
                        { field: 'ck', width: 50,checkbox:true },
                        { field: 'LRBH', title: '报表编码', width:100, formatter: function (val, rec) { return unescape(rec.LRBH); } },
                        {
                            field: 'BBMC', title: '报表名称', width: 180,
                            formatter: function (val, rec) {
                                if (rec.BZ=="")
                                    return unescape(val);
                                else
                                    return unescape(val + "-(" + rec.BZ + ")");
                            }
                        },
                        {
                            field: 'SFTGJY', title: '通过校验', width: 100,
                            formatter: function (val, rec) {
                                if (unescape(rec.SFTGJY)  == '是')
                                    return "<img src='/Resources/easyui-1.32/themes/icons/tick.png'/>";
                                else 
//                                    return "<span onmouseover=\"showinfo('" + dwbm + "','" + year + "','" + month + "','" + rec.BBBM + "',event,this)\" onmouseout=\"hideinfo('" + rec.DWBM + "','" + rec.NF + "','" + rec.YF + "','" + rec.BBBM + "')\"><img src='/Resources/easyui-1.32/themes/icons/cancel.png'/></span>";
       
                                  return "<a href=JYInfo.aspx?dwbm=" + dwbm + "&nf=" + year + "&yf=" + month + "&bbbm=" + rec.BBBM + " target=_blank onmouseout=\"hideinfo('" + rec.DWBM + "','" + rec.NF + "','" + rec.YF + "','" + rec.BBBM + "')\"><img src='/Resources/easyui-1.32/themes/icons/cancel.png'/></a>";
                       }
                        },
                        { field: 'BBZQ', title: '报表周期', width: 80, formatter: function (val, rec) { return unescape(rec.BBZQ); } },
                        { field: 'NF', title: '年份', width: 50, formatter: function (val, rec) { return unescape(rec.NF); } },
                         { field: 'YF', title: '月份', width: 50, formatter: function (val, rec) { return unescape(rec.YF); } },
                        { field: 'TJR', title: '上报人', width: 100,  formatter: function (val, rec) { return unescape(rec.TJR); } },
                        { field: 'TJSJ', title: '上报时间', width: 100, formatter: function (val, rec) { return unescape(rec.TJSJ); } },
                        {
                            field: 'BBZT', title: '报表状态', width: 100,
                            formatter: function (val, rec) { if (unescape(rec.BBZT) == '已上报') return "<img src='/Resources/easyui-1.32/themes/icons/lock.png'/>"; else return "<img src='/Resources/easyui-1.32/themes/icons/cancel.png'/>"; }
                        },
                        {
                            field: 'YQSBSJ', title: '要求上报时间', width: 120,
                            formatter: function (val, rec)
                            {
                                return unescape(rec.YQSBSJ);
                            }
                        }
                        //{ field: 'SHR', title: '审核人', width: 100, formatter: function (val, rec) { return unescape(rec.SHR); } },
                        //{ field: 'SHSJ', title: '审核人', width: 100,  formatter: function (val, rec) { return unescape(rec.SHSJ); } },
                        //{
                        //    field: 'SHZT', title: '审核状态', width: 100,
                        //    formatter: function (val, rec) { if (unescape(rec.SHZT) == '是') return "<img src=/Resources/easyui-1.32/themes/icons/lock.png/>"; else return "<img src=/Resources/easyui-1.32/themes/icons/cancel.png/>"; }
                        //}
                ]],
                toolbar: [{
                    text: '数据校验',
                    iconCls: 'icon-tick',
                    disabled:<%=(!Permissions[0].Allow).ToString().ToLower()%>,
                    handler: function () {
                        Xiaov.SmartWeb.Application.PluginSrc.StatisticalSystem.Manage.Index.Check(bbbms, dwbm, year, month, callback);
                    }
                }, '-', {
                    text: '上报',
                    iconCls: 'icon-lightning',
                    disabled:<%=(!Permissions[2].Allow).ToString().ToLower()%>,
                    handler: function () {
                        var bbbms = getReportSelections(); //获取所有通过校验的数据
                        var months = getSelections_yf();
                        if (bbbms)
                            Xiaov.SmartWeb.Application.PluginSrc.StatisticalSystem.Manage.Index.Report(bbbms, dwbm, year, months,sbr, callback);
                        else
                            alert('请选择已经通过校验的报表');
                    }
                }, '-', {
                    text: '解锁',
                    iconCls: 'icon-key',
                    disabled:<%=(!Permissions[3].Allow).ToString().ToLower()%>,
                    handler: function () {
                        var bbbms = getSelections();
                        var months = getSelections_yf();
                        if (bbbms)
                            Xiaov.SmartWeb.Application.PluginSrc.StatisticalSystem.Manage.Index.UnLock(bbbms, dwbm, year, months, callback);
                        else
                            alert('请选择行');
                    }
                }
                ]
            });
        });

       


    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div style="padding: 3px; font-size: 12px;">
        <asp:DropDownList ID="ddl_Owner" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddl_Owner_SelectedIndexChanged"
            ClientIDMode="Static">
        </asp:DropDownList>
        <asp:DropDownList ID="ddl_Year" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddl_Year_SelectedIndexChanged"
            ClientIDMode="Static">
        </asp:DropDownList>
        <asp:DropDownList ID="ddl_Month" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddl_Month_SelectedIndexChanged"
            ClientIDMode="Static">
        </asp:DropDownList>
        上报人：<asp:DropDownList ID="ddl_Sbr" runat="server" ClientIDMode="Static">
        </asp:DropDownList>
        <asp:Button ID="btnLock" runat="server" Text="全部锁定" OnClientClick="return confirm('确定全部锁定？')"
            OnClick="btnLock_Click" />
    </div>
    <div style="padding: 3px; font-size: 12px;">
        <table id="tt">
        </table>
    </div>
    <script>
        $('#tt').css('height', userScreenHeight - 40);
    </script>
    <p style="font-size: 12px; color: Red">
        注意：只有在【规定的时间内】选择要上报的报表 并【选择上报人姓名】才能上报。</p>
</asp:Content>
